package day07;

import java.util.Arrays;
import java.util.Scanner;

//6位评委打分，范围0-100间整数
//最后得分；去掉最高，强调最低后的四个评委平均分
public class CalTotaAvg {
    public static void main(String[] args) {


        double[] scores = enterData();//1.录入成绩;
        double total = calTotal(scores);//2.计算总分
        double avg = calAvg(scores);//3.计算平均得分
        System.out.println("平均成绩为：" + avg);//4.输出总分和平均分
    }
    public static double[] enterData(){
        Scanner scan=new Scanner(System.in);
        double[] scores=new double[6];
        for (int i=0;i< scores.length;i++){
            System.out.println("请录入第"+(i+1)+"个评委的分数：");
            scores[i]=scan.nextDouble();
        }
        return scores;
    }
    public static double calTotal(double[] scores){
        double total=0.0;
        double max= scores[0];
        double min= scores[0];
        for (int i=0;i< scores.length;i++){
            if (max<scores[i]){
                max=scores[i];
            }
            if (min>scores[i]){
                min=scores[i];
            }
            total += scores[i];
        }
        return total-max-min;

    }
    public static double calAvg(double[] scores){
        double total=calTotal(scores);
        double avg=0.0;
            avg=total/4;
            return avg;

        }



}

